﻿using System;
using System.Data;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using FFIV.Lib.DataComponent;
using FFIV.Lib.IView.Articles;
using FFIV.Lib.Utilities;

public partial class Views_Articles_ArticlesMiniList : System.Web.UI.UserControl, IArticlesMiniList
{

	public void RegisteEvents()
	{
		rp_Articles.ItemDataBound += rp_Articles_ItemDataBound;
	}

	private void rp_Articles_ItemDataBound(object sender, RepeaterItemEventArgs e)
	{
		DataRowView item = e.Item.DataItem as DataRowView;
		if (item != null)
		{
			HtmlAnchor article = e.Item.FindControl("lkb_Article") as HtmlAnchor;
			if (article != null)
			{
				string title = item["Title"].ToString();
				article.InnerText = title.Length >= 13 ? title.Substring(0, 13) + "..." : title;
				article.HRef = UrlUtility.GetArticleDetailUrl(Convert.ToInt32(item["ArticleId"]));
				article.Title = title;
			}
		}
	}

	public AritcleDS.ArticlesDataTable Articles
	{
		set
		{
			rp_Articles.DataSource = value;
			rp_Articles.DataBind();
		}
	}
}
